<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>地区管理</title>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
<link href="css_body.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.STYLE1 {
	color: #FF0000;
	font-weight: bold;
}
-->
</style>
</head>
<body>
<div class="bodytitle">
	<div class="bodytitleleft"></div>
	<div class="bodytitletxt">互动模块</div>
</div>
<?php
if(empty($action))
{
?>
<form name="form1" action="area.php" method="post">
<input type="hidden" name="action" value="add" />
<input type="hidden" name="reid" value="0" />
<table width="96%" border="0" cellpadding="1" cellspacing="1" align="center" class="tbtitle" style="	background:#E2F5BC;">
  <tr>
    <td height="20" colspan="2" bgcolor="#EDF9D5">&nbsp;<strong>添加一级地区 </strong></td>
  </tr>
  <tr>
  <td width="150" align="right" bgcolor="#FFFFFF">
   &nbsp;地区名称：</td>
    <td height="35" bgcolor="#FFFFFF"><input type="text" name="name" value="" /></td>
  </tr>
  <tr>
    <td align="right" bgcolor="#FFFFFF">&nbsp;</td>
    <td height="35" bgcolor="#FFFFFF">&nbsp;
    <input type="submit" name="submit1" value="提交" class="inputbut"/></td>
  </tr>
</table>
</form>

<form name="form2" action="area.php" method="post">

<table width="96%" border="0" cellpadding="1" cellspacing="1" align="center" class="tbtitle" style="	background:#E2F5BC;">
  <tr>
    <td height="20" colspan="2" bgcolor="#EDF9D5"><strong>&nbsp;添加二级地区</strong></td>
  </tr>
  <tr>
<input type="hidden" name="action" value="add" />
    <td width="150" align="right" bgcolor="#FFFFFF">
	地区名称：</td>
    <td bgcolor="#FFFFFF"><input type="text" name="name" value="" /></td>
  </tr>
  <tr>
    <td bgcolor="#FFFFFF">&nbsp;</td>
    <td bgcolor="#FFFFFF"><select name="reid">
      <option value="0">所属一级地区</option>
      <?php echo $sectorscache; ?>
    </select></td>
  </tr>
  <tr>
    <td height="35" bgcolor="#FFFFFF">&nbsp;</td>
    <td bgcolor="#FFFFFF">&nbsp;
    <input type="submit" name="submit2" value="提交" class="inputbut"/></td>
  </tr>
</table>
</form>

<form name="form3" action="area.php" method="post">
<input type="hidden" name="action" value="update" />
<table width="96%" border="0" cellpadding="1" cellspacing="1" align="center" class="tbtitle" style="	background:#E2F5BC;">
    <tr>
        <td height="20" bgcolor="#EDF9D5">&nbsp;<strong>编辑地区</strong></td>
    </tr>
      <tr>
        <td bgcolor="#FFFFFF">
<table width="100%" border="0" cellpadding="1" cellspacing="1" align="center" style="margin:0px auto" class="tblist">
          <tr>
            <td height="20">编号</td>
            <td height="20">名称</td>
            <td height="20">排序</td>
            <td height="20">管理操作</td>
          </tr>
          <?php
foreach($sectors as $sector)
{
	if($sector['reid'] == 0)
	{
		echo "<tr bgcolor=\"#f8f8f7\"><td>$sector[id]</td><td><input type=\"text\" name=\"names[$sector[id]]\" value=\"$sector[name]\" /></td><td><input type=\"text\" name=\"disorders[$sector[id]]\" value=\"$sector[disorder]\" /></td><td><a href=\"area.php?action=edit&amp;id=$sector[id]\">修改</a> <a href=\"area.php?action=delete&amp;id=$sector[id]\">删除</a></td></tr>";
	}else
	{
		echo "<tr><td>$sector[id]</td><td>|--<input type=\"text\" name=\"names[$sector[id]]\" value=\"$sector[name]\" /></td><td><input type=\"text\" name=\"disorders[$sector[id]]\" value=\"$sector[disorder]\" /></td><td><a href=\"area.php?action=edit&amp;id=$sector[id]\">修改</a> <a href=\"area.php?action=delete&amp;id=$sector[id]\">删除</a></td></tr>";

	}
}
?>
        </table></td>
    </tr>
      <tr>
        <td height="35" align="center" bgcolor="#FFFFFF"><input name="submit3" type="submit" value="全部更新" class="inputbut"/></td>
    </tr>
    </table>
</form>

<?php
}elseif($action == 'edit')
{
?>
<form name="form4" action="area.php" method="post">
<input type=hidden name=action value=edit />
<input type=hidden name=step value=2 />
<input type=hidden name=id value=<?php echo $id; ?> />
<table width="96%" border="0" cellpadding="1" cellspacing="1" align="center" class="tbtitle" style="	background:#E2F5BC;">
    <tr>
        <td height="20" colspan="2" bgcolor="#EDF9D5"><strong>&nbsp;修改</strong></td>
    </tr>
      <tr>
        <td width="150" align="right" bgcolor="#FFFFFF">所属地区：</td>
        <td bgcolor="#FFFFFF"><select name="reid">
          <?php echo $sectorscache; ?>
        </select>        </td>
    </tr>
      <tr>
        <td align="right" bgcolor="#FFFFFF">地区名称：</td>
        <td bgcolor="#FFFFFF"><input type=text name=name value=<?php echo $sector['name']; ?> /></td>
    </tr>
      <tr>
        <td align="right" bgcolor="#FFFFFF">顺序：</td>
        <td bgcolor="#FFFFFF"><input type=text name=disorder value=<?php echo $sector['disorder']; ?> /></td>
    </tr>
      <tr>
        <td height="35" bgcolor="#FFFFFF">&nbsp;</td>
        <td bgcolor="#FFFFFF"><input name="submit4" type="submit" value="提交" class="inputbut"/></td>
    </tr>
    </table>
</form>
<?php
}elseif($action == 'delete')
{
?>
<form action=area.php method=post name=form5>
<input type=hidden name=action value=delete />
<input type=hidden name=step value=2 />
<input type=hidden name=id value=<?php echo $id; ?> />
<table width="96%" border="0" cellpadding="1" cellspacing="1" align="center" class="tbtitle" style="	background:#E2F5BC;">
  <tr>
    <td bgcolor="#EDF9D5">&nbsp;<strong>删除地区确认&nbsp;</strong></td>
  </tr>
  <tr>
    <td height="80" align="center" bgcolor="#FFFFFF"><span class="STYLE1">删除地区时将删除该地区的所有下级地区，且不能恢复操作，请确认删除！      </span></td>
  </tr>
  <tr>
    <td height="35" align="center" bgcolor="#FFFFFF"><input name="submit5" type="submit" value="确认删除" class="inputbut"/>
      &nbsp;
      <input type='button' value='返 回 继 续 操 作' onclick='javascript:history.go(-1);' class="inputbut"/></td>
  </tr>
</table>
</form>
<?php
}
?>
</body>
</html>